//
//  SetUserIndustryView.swift
//  IdleFish
//
//  Created by Ben on 2022/1/16.
//

import SwiftUI

let INDUSTRY_SOURCE: [String] = [
    "学生",
    "自由职业",
    "IT/互联网/通信",
    "金融",
    "健康/医疗",
    "工业/制造业",
    "零售",
    "贸易",
    "教育/科研",
    "培训",
    "房地产/建筑",
    "文化/艺术",
    "影视/娱乐",
    "法律/会计/公关",
    "体育/健身",
    "国家机关单位",

]

struct SetUserIndustryView: View {
    
    @EnvironmentObject var userDataVM: UserDataViewModel

    
    var body: some View {
        
        VStack(alignment: .leading) {
            // 这里添加一个右侧的按钮
            CustomNavView(title: "选择行业") {
                userDataVM.showIndustryPicker.toggle()
            }
            
            List(INDUSTRY_SOURCE, id: \.self) { industry in
                HStack {
                    Text(industry)
                        .font(.system(size: 16, weight: userDataVM.initVM?.userInfo?.industry == industry ? .bold : .regular))
                    
                    Spacer()
                    
                    Image(systemName: "checkmark")
                        .font(.system(size: 14))
                        .opacity(userDataVM.initVM?.userInfo?.industry == industry ? 1 : 0)
                }
                .contentShape(Rectangle())
                .frame(height: 45)
                .listRowSeparator(.hidden)
                .onTapGesture {
                    userDataVM.selectedIndustry = industry
                    
                }
            }
            .listStyle(.plain)
        }
        .navigationBarHidden(true)
        .navigationTitle("")
    }
}

struct SetUserIndustryView_Previews: PreviewProvider {
    static var previews: some View {
        SetUserIndustryView()
    }
}
